package cn.com.pc.content.domain.abuse;

import cn.com.pc.content.domain.content.ContentType;
import cn.com.pc.content.domain.Site;
import cn.com.pc.content.jpa.SiteConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import lombok.ToString;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * 滥用举报
 */
@Data
@ToString
@Entity
@Table(name = "abuse_reports")
public class AbuseReport {
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "site")
    @Convert(converter = SiteConverter.class)
    private Site site;

    @Column(name = "content_type")
    private ContentType contentType;

    @Column(name = "content_id")
    private Long contentId;

    @Column(name = "reasons")
    private String reasons;

    @Column(name = "passport_id")
    private Long passportId;

    @Column(name = "contact")
    private String contact;

    @JsonFormat(timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss", shape = JsonFormat.Shape.STRING)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @Column(name = "created_at")
    private LocalDateTime createdAt;

    /**
     * 常用的举报原因，http://www.cac.gov.cn/2019-12/20/c_1578375159509309.htm
     */
    public enum RegularReason {
        Law("违背法律法规"),
        Vulgar("低俗色情"),
        Terrorism("恐怖主义"),
        Violence("血腥/暴力/犯罪"),
        Ad("垃圾广告"),
        Rumor("谣言/诽谤"),
        Privacy("侵犯隐私"),
        Format("排版错乱"),
        Title("标题不当"),
        Content("内容不当"),
        FakeContent("虚假内容"),
        CopyRight("版权/抄袭");

        private final String fullname;

        RegularReason(String fullname) {
            this.fullname = fullname;
        }

        public String getFullname() {
            return fullname;
        }
    }
}
